using Devonline.AspNetCore;
using Devonline.Communication.Messages;
using Devonline.Communication.SerialPorts;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Serilog;

var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((context, logger) => logger.ReadFrom.Configuration(context.Configuration));
builder.AddCommunicator();
builder.AddSetting<SerialPortOptions>(nameof(System.IO.Ports.SerialPort));

// Add services to the container.
var services = builder.Services;
services.AddLogging();
var app = builder.Build();
app.Services.GetRequiredService<IMessageCommunicator>().StartAsync();
app.Run();